package icu.sehnen.user.controller;


import icu.sehnen.common.result.CommonResult;
import icu.sehnen.user.entity.Permission;
import icu.sehnen.user.service.IPermissionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 后台用户权限表 前端控制器
 * </p>
 *
 * @author icu.sehnen
 * @since 2021-04-27
 */
@Api(value = "用户controller",tags = {"用户操作接口"})
@RestController
@RequestMapping("/user/permission")
public class PermissionController {

    @Autowired
    IPermissionService permissionService;
    @ApiOperation(value = "获取所有权限",tags = "获取所有权限")
    @GetMapping("/list")
    public CommonResult<List<Permission>> getPermission(){
        List<Permission> permissionList= permissionService.list();
        return CommonResult.success(permissionList);
    }
    @ApiOperation(value = "根据用户Id获取菜单")
    @GetMapping("/menus/{id}")
    public CommonResult getMenusById(@ApiParam(name="id",value="用户名ID") @PathVariable("id") Long id){
        List<Permission> permissionList = permissionService.getMenusById(id);
        return CommonResult.success(permissionList);
    }
    @GetMapping("/tree")
    public CommonResult findTree(){
        List<Permission> progressList = permissionService.getPermission();
        return CommonResult.success(progressList);
    }

}